<?php
/*
	
*/
defined('BY_JYA') or exit('Access Denied');
global $_RQ,$_AR;

$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';

$basic=$this->plugin_setting('basic');
$return['banner']=$basic['image'];
$return['basic']=$basic;
//我的收藏
if($_RQ['op']=='main'){
	$shoucanglist=pdo_getall('jy_vote_shoucang',array('uniacid'=>$_SESSION['uniacid'],'isshoucang'=>1,'mid'=>$_SESSION['uid']),'','createtime desc');
	$list=array();
	if($shoucanglist){
		foreach($shoucanglist as &$item){
			$opus=pdo_get('jy_vote_opus',array('id'=>$item['oid'],'uniacid'=>$_SESSION['uniacid']));
			if(empty($opus)){
				pdo_delete('jy_vote_shoucang',array('uniacid'=>$_SESSION['uniacid'],'oid'=>$item['oid']));
			}else{
				array_push($list,$opus);
			}
		}
	}
	if($list){
		$sum=count($list);
		foreach($list as &$item){
			$reply=pdo_get('jy_vote_reply',array('id'=>$item['rid'],'uniacid'=>$_SESSION['uniacid']));
			$item['createtime']=date('Y-m-d H:i:s',$item['createtime']);
			$item['reply']=$reply;
			$item['opus_images']=json_decode($item['opus_images'],true);
			$item['picsnum']=count($item['opus_images']);
			$item['votenums']=pdo_count('jy_vote_votelog',array('oid'=>$item['id'],'uniacid'=>$_SESSION['uniacid'],'is_shenhe'=>1));
			$item['group']=pdo_get('jy_vote_groups',array('uniacid'=>$_SESSION['uniacid'],'id'=>$reply['groupid']));
			$jifen=pdo_getsum('jy_vote_sendlplog',array('oid'=>$item['id'],'uniacid'=>$_SESSION['uniacid'],'status'=>1),'jifen');
			$item['votenums']=$item['votenums']+$jifen;
			$item['likes']=$item['likes']+$jifen;
			$member=pdo_get('core_members',array('id'=>$item['mid'],'uniacid'=>$_SESSION['uniacid']),array('credit1','credit2','mobile','groupid','avatar','nickname'));
			$item['lealname']=$item['lealname']?$item['lealname']:$member['nickname'];
		}
	}
	$return['list']=$list;
	$return['sum']=$sum;
	exi($return);

}
